import h5py

# 替换为你的 H5 文件路径
h5_file_path2 = './data/cad_vec/0000/00008381.h5'
h5_file_path = './proj_log/newDeepCAD/results/test_1000/00008381_vec.h5'
# 打开 H5 文件并打印内容
with h5py.File(h5_file_path2, 'r') as file:
    # 打印文件中所有数据集的名称
    print("Datasets in the H5 file:")
    file.visit(print)

    # 读取并打印特定数据集（例如 'out_vec'）
    if 'vec' in file:
        vec = file['vec'][:]
        print("Content of 'vec':", vec)
        print(vec.shape)
    if 'gt_vec' in file:
        gt_vec = file['gt_vec'][:]
        print("Content of 'gt_vec':", gt_vec)
        print(gt_vec.shape)
    if 'out_vec' in file:
        out_vec = file['out_vec'][:]
        print("Content of 'out_vec':", out_vec)
        print(out_vec.shape)
    else:
        print("'out_vec' dataset not found.")

with h5py.File(h5_file_path, 'r') as file:
    # 打印文件中所有数据集的名称
    print("Datasets in the H5 file:")
    file.visit(print)

    # 读取并打印特定数据集（例如 'out_vec'）
    if 'vec' in file:
        vec = file['vec'][:]
        print("Content of 'vec':", vec)
        print(vec.shape)
    if 'gt_vec' in file:
        gt_vec = file['gt_vec'][:]
        print("Content of 'gt_vec':", gt_vec)
        print(gt_vec.shape)
    if 'out_vec' in file:
        out_vec = file['out_vec'][:]
        print("Content of 'out_vec':", out_vec)
        print(out_vec.shape)
    else:
        print("'out_vec' dataset not found.")








